import request from '@/utils/request'

// 查询流程定义列表
export function listDefinition(query) {
  return request({
    url: '/flow/definition/list',
    method: 'get',
    params: query
  })
}

// 查询流程定义详细
export function getDefinition(id) {
  return request({
    url: '/flow/definition/' + id,
    method: 'get'
  })
}

// 查询流程定义详细
export function exportDefinition(id) {
  return request({
    url: '/flow/definition/exportDefinition/' + id,
    method: 'get'
  })
}

// 新增流程定义
export function addDefinition(data) {
  return request({
    url: '/flow/definition',
    method: 'post',
    data: data
  })
}

// 修改流程定义
export function updateDefinition(data) {
  return request({
    url: '/flow/definition',
    method: 'put',
    data: data
  })
}

// 删除流程定义
export function delDefinition(id) {
  return request({
    url: '/flow/definition/' + id,
    method: 'delete'
  })
}

// 保存流程结点
export function saveNode(data, definitionId) {
  return request({
    url: '/flow/definition/saveNode?definitionId=' + definitionId,
    method: 'post',
    data: data
  })
}

// 查询流程结点详细
export function getNodeList(definitionId) {
  return request({
    url: '/flow/definition/getNodeList/' + definitionId,
    method: 'get'
  })
}

// 查询流程跳转详细
export function getSkipList(nodeId) {
  return request({
    url: '/flow/definition/getSkipList/' + nodeId,
    method: 'get'
  })
}

// 保存流程跳转
export function saveSkip(data, nodeId) {
  return request({
    url: '/flow/definition/saveSkip?nodeId=' + nodeId,
    method: 'post',
    data: data
  })
}

// 发布流程定义
export function publish(id) {
  return request({
    url: '/flow/definition/publish/' + id,
    method: 'get'
  })
}

// 取消发布流程定义
export function unPublish(id) {
  return request({
    url: '/flow/definition/unPublish/' + id,
    method: 'get'
  })
}
